package com.ruoyi.xsp.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.xsp.mapper.XspNewsInfoMapper;
import com.ruoyi.xsp.domain.XspNewsInfo;
import com.ruoyi.xsp.service.IXspNewsInfoService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;

/**
 * 视频管理Service业务层处理
 * 
 * @author zhiminhu
 * @date 2021-01-22
 */
@Service
public class XspNewsInfoServiceImpl implements IXspNewsInfoService 
{
    @Autowired
    private XspNewsInfoMapper xspNewsInfoMapper;

    /**
     * 查询视频管理
     * 
     * @param newsId 视频管理ID
     * @return 视频管理
     */
    @Override
    @Transactional
    public XspNewsInfo selectXspNewsInfoById(Long newsId)
    {
        XspNewsInfo xspNewsInfo=   xspNewsInfoMapper.selectXspNewsInfoById(newsId);
        if(xspNewsInfo!=null) {
            xspNewsInfo.setReadCount(xspNewsInfo.getReadCount() + 1);
            xspNewsInfoMapper.updateXspNewsInfo(xspNewsInfo);
        }
        return xspNewsInfo;
    }

    /**
     * 查询视频管理列表
     * 
     * @param xspNewsInfo 视频管理
     * @return 视频管理
     */
    @Override
    public List<XspNewsInfo> selectXspNewsInfoList(XspNewsInfo xspNewsInfo)
    {
        return xspNewsInfoMapper.selectXspNewsInfoList(xspNewsInfo);
    }
    /**
     * 我关注用户视频列表
     * @param xspNewsInfo
     * @return
     */
    @Override
    public List<XspNewsInfo> selectXspNewsInfoListByMyConcerned(XspNewsInfo xspNewsInfo)
    {
        return xspNewsInfoMapper.selectXspNewsInfoListByMyConcerned(xspNewsInfo);

    }
    /**
     * 我喜欢的视频列表
     * @param xspNewsInfo
     * @return
     */
    @Override
    public List<XspNewsInfo> selectXspNewsInfoListByMyLike(XspNewsInfo xspNewsInfo){
        return xspNewsInfoMapper.selectXspNewsInfoListByMyLike(xspNewsInfo);
    }
    /**
     * 新增视频管理
     * 
     * @param xspNewsInfo 视频管理
     * @return 结果
     */
    @Override
    public int insertXspNewsInfo(XspNewsInfo xspNewsInfo)
    {
        xspNewsInfo.setCreateTime(DateUtils.getNowDate());
        return xspNewsInfoMapper.insertXspNewsInfo(xspNewsInfo);
    }

    /**
     * 修改视频管理
     * 
     * @param xspNewsInfo 视频管理
     * @return 结果
     */
    @Override
    public int updateXspNewsInfo(XspNewsInfo xspNewsInfo)
    {
        return xspNewsInfoMapper.updateXspNewsInfo(xspNewsInfo);
    }

    /**
     * 删除视频管理对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteXspNewsInfoByIds(String ids)
    {
        return xspNewsInfoMapper.deleteXspNewsInfoByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除视频管理信息
     * 
     * @param newsId 视频管理ID
     * @return 结果
     */
    @Override
    public int deleteXspNewsInfoById(Long newsId)
    {
        return xspNewsInfoMapper.deleteXspNewsInfoById(newsId);
    }
}
